<?php
	header('Content-Type: application/json; charset=UTF-8');
	$arrResult = array();
	$arrResult['result'] = false;
	if(isset($_GET['action'])) {
		switch($_GET['action']){
			case 'is_admin':
				if(isset($_SESSION['user_name']) && isset($_SESSION['user_id']) && isset($_GET['uid'])) {
					$arr = array("9153971", "2362690", "8309790", "7842042");
					if(array_search($_GET['uid'], $arr) !=-1){
						$result = true;
					}
				} else {
					$result = false;
				}
			break;
			case 'is_login':
				if(isset($_SESSION['user_name']) && isset($_SESSION['user_id'])) {
					$result = true;
					$arrResult['user_name'] = $_SESSION['user_name'];
					$arrResult['user_id'] = $_SESSION['user_id'];
				} else {
					$result = false;
				}
			break;
			case 'login':
				if(isset($_GET['uname']) && isset($_GET['uid'])){
					$_SESSION['user_name'] = $_GET['uname'];
					$_SESSION['user_id'] = $_GET['uid'];
					$result = true;
				} else {
					$result = false;
				}
			break;
			case 'logout':
				$_SESSION['user_name'] = null;
				$_SESSION['user_id'] = null;
				$result = true;
			break;
		}
	}
	$arrResult['result'] = $result;
//	echo $_SESSION['user_name'].$_SESSION['user_id'];
	echo json_encode($arrResult, JSON_UNESCAPED_UNICODE);
?>